

using System;
using System.Data;
using System.Diagnostics;
using System.Xml;
using System.ComponentModel;
using System.Collections;
using System.IO;


using CStock;
using CUtil;
using CIndicators;




//problem
//the path var.is not set after deserialization !

//TODO
//Value_Total is not reflecting the current value of the portfolio (Because it would mean an update - and reading 
//of all share data at start
//to update - call Value_TotalUpdate
namespace CStock
{
	[System.Xml.Serialization.XmlRoot()]
	public class DataItemFactory : Factory , IDataItemFactory
    {
		#region fields

        IDataItem dataItem;
		

		#endregion



        public DataItemFactory()
		{
            dataItem = new DataItem();
            this.stockObjectBase = dataItem as StockObjectBase;
            
        }

           public IDataItem DataItem
        {
            get
            {
                return dataItem;
            }
            set
            {
                dataItem = value;
            }
        }

        
        public override bool Create_TestData()
        {
            base.Create_TestData();
            DataClassFactory dcf = new DataClassFactory();
            dcf.Create_TestData(100);
            //DataClass dc = new DataClassDaily();
            this.dataItem.DataClass = dcf.StockObjectBase as IDataClass;
            //Debug.Assert(false, "Not implemented");
            

            return true;

        }
        public override bool Create(string id)
        {
            this.dataItem = new DataItem();

           
            this.DataItem.ID = id;
            return true;

        }
        public override bool Serialize()
        {


            return dataItem.Serialize();


        }


        public override bool RemoveAll()
        {
            return XMLSerializable.RemoveAllXML(this.dataItem.Path);

        }



        /// <summary>
        /// attention - new object variable for dataClass!!
        /// </summary>
        /// <returns></returns>
        public override bool DeSerialize()
        {
            if (base.DeSerialize())
            {
                
                this.dataItem = this.stockObjectBase as IDataItem;
                return true;
            }
            return false;

           


        }
        public static bool AddTestData(int i)
        {
            Debug.Assert(false, "Not implemented");

            return true;

        }

     
	}
}
